﻿using UnityEngine;

public class ReconnectMgr : Singleton<ReconnectMgr>
{
    private ReconnectPanel view;
    private bool isNewConnect;

    public ReconnectMgr()
    {
        Transform trans = AllUpdate.GetChildByName("Reconnect");
        view = new ReconnectPanel(trans.gameObject);
        Utility.SetActive(trans, false);
        UIEventListener.Get(view.Dialog_obj).onClick = OnClick;
    }

    public void Open(bool isNewConnect = true)
    {
        this.isNewConnect = isNewConnect;
        Utility.SetActive(view.Go, true);
    }

    public void Close()
    {
        Utility.SetActive(view.Go, false);
    }
    
    private void OnClick(GameObject obj)
    {
        if (obj == view.Dialog_obj)
        {
            if(!isNewConnect)
            {
                GameClient.GetSingleton().AddReconnectNum();
            }
            GameClient.GetSingleton().NewConnectGate();
        }
    }
}